export const BOOK_STATUS = {
	already: 2,
	wait: 1,
	draft: -1
};

export const formList = [];

export const getSearchOptions = (info: string) => {
	return [
		{
			type: "input",
			placeholder: "书籍名称",
			name: "book_name"
		},

		{
			type: "input",
			placeholder: "作者名称",
			name: "book_author"
		}
	];
};

export const TABS = [
	{
		label: "全部",
		key: "all"
	},
	{
		label: "已上架",
		key: "2"
	},
	{
		label: "待上架",
		key: "1"
	},
	{
		label: "已下架",
		key: "-1"
	}
];

export const getTableColumns = ({ params }) => [
	{
		title: "书籍名称",
		dataIndex: "book_name",
		width: 140,
		ellipsis: true
	},
	{
		title: "作者名称",
		dataIndex: "book_author",
		width: 140,
		ellipsis: true
	},
	{
		title: "福贝值",
		dataIndex: "points",
		width: 100,
		ellipsis: true
	},
	{
		title: "加入书架量",
		dataIndex: "shelf_count",
		width: 100,
		ellipsis: true
	},
	{
		title: "累计阅读量",
		dataIndex: "read_count",
		width: 100,
		ellipsis: true
	},
	{
		title: "创建时间",
		dataIndex: "created_at",
		width: 140,
		ellipsis: true
	},
	{
		title: "状态",
		dataIndex: "book_status",
		width: 140,
		render: (_: any, record: any) => {
			const value = record?.book_status;
			let result: any = {};
			switch (value) {
				case BOOK_STATUS.already:
					result = {
						label: "已上架",
						color: "#0B801E",
						bgColor: "#E5FDE9"
					};
					break;
				case BOOK_STATUS.wait:
					result = {
						label: "待上架",
						color: "#DE6700",
						bgColor: "#FFF8ED"
					};
					break;
				case BOOK_STATUS.draft:
					result = {
						label: "已下架",
						color: "#DE6700",
						bgColor: "#FFF8ED"
					};
					break;
				default:
					result = {
						label: "-",
						color: "#7E7E7E",
						bgColor: "#e6e6e6"
					};
					break;
			}
			return (
				<span style={{ color: result?.color, background: result?.bgColor, padding: "3px 10px", borderRadius: "4px" }}>
					{result.label}
				</span>
			);
		}
	}
];

export const ADD_BOOK_TYPE = {
	chapter: 1,
	section: 2,
	page: 3
} as const;
